package com.carcenter.generator;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.OutputFile;

import java.util.Collections;

public class SystemGenerator {
    public static void main(String[] args) {
        //修改路径,Src上面的根目录；
        String path = "D:\\IDEA\\ideaprojects\\carcenter\\carcenter-service\\carcenter-service-order";

        String pathCode = path + "\\src\\main\\java";
        String pathMapper = path + "\\src\\main\\resources\\mapper";

        // 连接数据库
        FastAutoGenerator.create(
                        "jdbc:mysql://192.168.126.102:3330/car_order", "root", "root")

                .globalConfig(builder -> {
                    builder.author("car") // 设置作者
                            .enableSwagger() // 开启 swagger 模式
                            .fileOverride() // 覆盖已生成文件
                            //.dateType(DateType.ONLY_DATE)
                            .disableOpenDir()
                            .outputDir(pathCode); // 指定输出目录
                })
                .packageConfig(builder -> {
                    builder.parent("com.carcenter.order") // 设置父包名
                            .moduleName(null) // 设置父包模块名
                            .pathInfo(Collections.singletonMap(
                                    OutputFile.xml, pathMapper)); // 设置mapperXml生成路径
                })
                .strategyConfig(builder -> {
                    builder.entityBuilder().enableLombok();
                    builder.controllerBuilder().enableHyphenStyle().enableRestStyle();
                    builder.addInclude("appointment_detail","appointment_master","appointment_process","car_brands","order_info","product_brands","products","services","specifications","units","vehicle_models") ;// 设置需要生成的表名
//                            .addTablePrefix("u_"); // 设置过滤表前缀

                })
                .execute();
    }
}
